<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/public.css" />
    <link href="__PUBLIC__/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="__PUBLIC__/bootstrap/css/button.css" rel="stylesheet">
    <script src="__PUBLIC__/bootstrap/js/jquery-1.9.1.js"></script>
    <script src="__PUBLIC__/bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript" src="__PUBLIC__/uploadify-v3.1/jquery.uploadify-3.1.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/ThinkBox/jquery.ThinkBox.js"></script>
    <script src="http://api.html5media.info/1.1.4/html5media.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/zeroclipboard/ZeroClipboard.js"></script>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/ThinkBox/css/ThinkBox.css" media="all">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/uploadify-v3.1/uploadify.css" media="all">
    <script type="text/javascript">
        window.UEDITOR_HOME_URL="__ROOT__/Data/ueditor/";
        window.onload=function(){
            window.UEDITOR_CONFIG.initialFrameHeight=400;
            window.UEDITOR_CONFIG.initialFrameWidth=965;
            UE.getEditor('content');
        };
    </script>
    <script type="text/javascript">
        var old_val='';
        var new_val='';
        var old_file_val='';
        var new_file_val='';
        function del_vedio(o) {
            new_val='';
            old_val='';
            var parent = $(o).parent().parent();
            var str = parent.attr('data-path');
            var arr = str.split('+');
            var path = arr[0];
            if (confirm('راستىنلا ئۆچۈرەسىز ؟')) {
                $.ajax({
                    type: "POST",   //访问WebService使用Post方式请求
                    url: '<?php echo U(GROUP_NAME."/Content/del_vedio");?>', //调用WebService的地址和方法名称组合---WsURL/方法名
                    data: "path=" + encodeURI(path),
                    success: function (data) {
                        if(data){
                            parent.animate({opacity: 'hide'}, "slow");
                            parent.removeClass('video_box');
                            bismillah();
                        }else{
                            alert('删除失败');
                        }
                    }
                });
            }
        }
        function del_file(o) {
            new_file_val='';
            old_file_val='';
            var parent = $(o).parent().parent();
            var str = parent.attr('data-path');
            var arr = str.split('+');
            var path = arr[0];
            if (confirm('راستىنلا ئۆچۈرەسىز ؟')) {
                $.ajax({
                    type: "POST",   //访问WebService使用Post方式请求
                    url: '<?php echo U(GROUP_NAME."/Content/del_vedio");?>', //调用WebService的地址和方法名称组合---WsURL/方法名
                    data: "path=" + encodeURI(path),
                    success: function (data) {
                        if(data){
                            parent.animate({opacity: 'hide'}, "slow");
                            parent.removeClass('file_box');
                            muhemmed();
                        }else{
                            alert('删除失败');
                        }
                    }
                });
            }
        }
        $(function () {
            $("#upload1").uploadify({
                'queueSizeLimit': 5,
                'removeTimeout': 0.5,
                'preventCaching': true,
                'multi': true,
                'swf': '__PUBLIC__/uploadify-v3.1/uploadify.swf',
                'uploader': '<?php echo U(GROUP_NAME."/Content/upload_video");?>',
                'buttonText': '<img src="__PUBLIC__/Images/add_v.png">',
                'width': '84',
                'height': '30',
                'fileTypeExts': '*.mp4;',
                'onUploadSuccess': function (file, data, response) {
                    var data = $.parseJSON(data);
                    if (data['status'] == 0) {
                        $.ThinkBox.error(data['info'], {'delayClose': 3000});
                        return;
                    }
                    var img = '<li class="video_box"  data-src="__PUBLIC__/Images/add.png' + data['data'] + '" data-path="' + data['data'] + '">' +
                            '<i style="display: none">'+data['data']+'</i>'+ '<b style="display: none">'+file['name']+'</b>'+
                            '<span class="img"><img src="__PUBLIC__/Images/video.png" width="100" height="80" border="0"/></span>' +
                            '<span class="control"><a href="javascript:;" onclick="del_vedio(this)" >' +
                            '<img src="__PUBLIC__/Images/delete.gif" alt="直接删除" title="直接删除" />' +
                            '</a></span><div class="selected" >'+file['name']+'</div></li>'
//                            '</a></span><div class="selected" >'+data['data']+'</div></li>'
                    //两个预览窗口赋值
                    $('#video_list').append(img);
                    //隐藏表单赋值
                    /*第一张图片为封面*/
                    $('#album1').val(data['data'] + ',' + $('#album1').val());
                    $('#con_video_old_name').val(file['name']+"," +$('#con_video_old_name').val());
                }
            });
            $("#upload_file").uploadify({
                'queueSizeLimit': 20,
                'removeTimeout': 0.5,
                'preventCaching': true,
                'multi': true,
                'swf': '__PUBLIC__/uploadify-v3.1/uploadify.swf',
                'uploader': '<?php echo U(GROUP_NAME."/Content/upload_file");?>',
                'buttonText': '<img src="__PUBLIC__/Images/add_f.png">',
                'width': '84',
                'height': '30',
                'fileTypeExts': '*.excel; *.pdf; *.zip;*.rar;*.xlsx;*.xlsx;*.xlsm;*.xls;',
                'onUploadSuccess': function (file, data, response) {
                    var data = $.parseJSON(data);
                    if (data['status'] == 0) {
                        $.ThinkBox.error(data['info'], {'delayClose': 3000});
                        return;
                    }
                    //var img='<img src="__PIC_URL__/'+data['data']+'?random='+Math.random()+'" width="100" height="80" /> ';
                    var img = '<li class="file_box" data-src="__PUBLIC__/Images/add.png' + data['data'] + '" data-path="' + data['data'] + '">' +
                            '<i style="display: none">'+data['data']+'</i>'+ '<b style="display: none">'+file['name']+'</b>'+
                            '<span class="img"><img src="__PUBLIC__/Images/video.png" width="100" height="80" border="0"/></span>' +
                            '<span class="control"><a href="javascript:;" onclick="del_file(this)" >' +
                            '<img src="__PUBLIC__/Images/delete.gif" alt="直接删除" title="直接删除" />' +
                            '</a></span><div class="selected" >'+file['name']+'</div></li>'
                    //两个预览窗口赋值
                    $('#file_list').append(img);
                    //隐藏表单赋值
                    /* 第一张图片为封面*/
                    $('#album2').val(data['data'] + ',' + $('#album2').val());
                    $('#con_file_old_name').val(file['name']+"," +$('#con_file_old_name').val());
                }
            });
        });

        /*
         * */
        function bismillah(){
            var len=parseInt($('.video_box').length);
            for (var i=0;i<len;i++)
            {
                old_val=$('.video_box:eq('+i+')').find('i').text()+','+old_val;
                new_val=$('.video_box:eq('+i+')').find('b').text()+','+new_val;

            }
            $('#con_video_old_name').val(new_val);
            $('#album1').val(old_val);
        }
        /*
         * */
        function muhemmed(){
            var len=parseInt($('.file_box').length);
            for (var i=0;i<len;i++)
            {
                old_file_val=$('.file_box:eq('+i+')').find('i').text()+','+old_file_val;
                new_file_val=$('.file_box:eq('+i+')').find('b').text()+','+new_file_val;

            }
            $('#con_file_old_name').val(new_file_val);
            $('#album2').val(old_file_val);

        }
    </script>
    <script type="text/javascript" src="__ROOT__/Data/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="__ROOT__/Data/ueditor/ueditor.all.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Js/ghulam.js"></script>
</head>
<body>
<form action="<?php echo U(GROUP_NAME.'/Content/run_addcontent');?>" method="post" enctype="multipart/form-data" id="add-form" onsubmit="return false">
    <table class="table table-striped table-hover">
        <tr>
            <td align="left  "><h3>添加内容</h3></td><td></td>
        </tr>
        <tr>
            <td><h5>内容栏目</h5></td>
            <td>
                <input type="hidden" name="con_category"  value="<?php echo ($cat_en_name); ?>"><b style="  font-size: 18px;
  color: rgb(51, 122, 183);"><?php echo ($cat_name); ?></b>
            </td>
        </tr>
        <tr>
            <td><h5>内容标题</h5></td>
            <td><input name="con_title" class="form-control text"/></td>
        </tr>
        <tr>
            <td><h5>是否内部</h5></td>
            <td>
                公开：  <input type="radio" value="0"  checked="checked" name="security">
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;内部：   <input type="radio" value="1" name="security">
            </td>
        </tr>
        <tr>
            <td><h5>封面图片</h5></td>
            <td >
                <div style="width: 100px;height: 32px;float: left;"><a href="javascript:;" class="a-upload btn-primary">封面图片
                    <input type=file name="con_thomb_pic" id="doc" onchange="javascript:setImagePreview();" accept="image/gif,image.png,image/jpeg,image.jpg"/>
                </a></div>

                <div style="display: initial;" id="localImag"><img id="preview" width=-1 height=-1 style="diplay:none" /></div>
            </td>
        </tr>
        <tr>
            <td><h5>内容视频</h5></td>
            <td>
                <div style="width:100%; height:auto; border:1px solid #e1e1e1; font-size:12px; padding:10px;">
                    <div id="thumbnails1">
                        <ul id="video_list" style="margin:5px;" class="album"></ul>
                        <div style="clear: both;"></div>
                    </div>
                    <input type="file" id="upload1" name="upload1" size="2" accept="video/mp4"/>
                    <input  name="con_video"      type="hidden" id="album1" accept="video/mp4"/>
                    <input  name="video_old_name" type="hidden" id="con_video_old_name"/>
                </div>
            </td>
        </tr>
        <tr><td><h5>内容</h5></td>
            <td>
                <textarea name="content" id="content"></textarea>
            </td>
        </tr>
        <tr>
            <td><h5>文件</h5></td>
            <td>
                <div style="width:100%; height:auto; border:1px solid #e1e1e1; font-size:12px; padding:10px;">
                    <div id="thumbnails2">
                        <ul id="file_list" style="margin:5px;" class="album"></ul>
                        <div style="clear: both;"></div>
                    </div>
                    <input type="file" id="upload_file" name="upload_file" size="2"/>
                    <input name="con_file"      type="hidden"  id="album2"/>
                    <input name="file_old_name" type="hidden"  id="con_file_old_name"/>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center"><input type="submit" id="save" class="btn btn-primary"></td>
        </tr>
    </table>
</form>
</body>
</html>